module.exports = async function (taskNoteId) {
  const taskNote = await api.getNote(taskNoteId);
  if (!taskNote) {
    return;
  }

  let dueDate = taskNote.getLabelValue("dueDate");

  if (!dueDate) {
    taskNote.removeLabel("timeLeft");

    return;
  }

  const today = api.dayjs();

  dueDate = api.dayjs(dueDate);

  const diff = today.diff(dueDate, "day");
     
  if (diff > -1) {
    taskNote.setLabel("timeLeft", diff ? "Time is up" : "Today");

    return;
  }

  taskNote.setLabel("timeLeft", api.dayjs(dueDate - today).format("D[d]"));
    
};
